<template>
    <el-dialog
      class="eldialog el-dialog-m0"
      :visible.sync="visible"
      :title="title"
      :close-on-click-modal="false"
      append-to-body
      top="2vh"
      width="50%"
      :close-on-press-escape="false"
    >
      <el-form ref="moduleForm" :model="dataForm" label-width="100px">
        <el-row>
  
          <el-col :span="12" :style="{height:heightY}">
            <iframe
              v-if="pdfUrl"
              type="iframe"
              aspect="1by1"
              :src="'data:application/pdf;base64,'+pdfUrl"
              allowfullscreen
              :style="{height:heightY,width:widthY}"
            />
          </el-col>
        </el-row>
      </el-form>
  
    </el-dialog>
  </template>
  
  <script>
    import {urlToBase64} from '@/api/young/evaluation/infoAudit/infoAudit.js'
      import webapp from '@/config/webapp'
      export default {
          components: {},
          data() {
              return {
                  dataForm: null,
                  title: '文件预览',
                  visible: false,
                  //                valid: '',
                  pdfUrl: '',
                  //    selected: [],
                  heightY: window.innerHeight - 90 + 'px',
                  heightZ: window.innerHeight - 360 + 'px',
                  widthY: window.innerWidth / 2 - 50 + 'px',
              }
          },
          methods: {
              async initShow(fileurl) {
                  // fileurl=webapp.GHB_URL+fileurl;
                  this.pdfUrl = '';
                  this.showFile(fileurl)
                  this.visible = true
                  // eslint-disable-next-line no-unused-vars
              },
              // pdf展示
              showFile(url) {
                console.log(url,"url")
                var parmas = {
                  "url":url
                }
                urlToBase64(parmas).then(result => {
                  this.pdfUrl = result
                })
              },
          }
      }
  </script>
  
  <style scoped>
  
  </style>
  